import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import UnoCSS from 'unocss/vite'
import { presetUno, presetAttributify, presetIcons } from 'unocss'
// vant组件
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';

// https://vite.dev/config/
export default defineConfig({
  server: {
    host: '0.0.0.0',
    port: 8081,
  },
  plugins: [
    vue(),
    UnoCSS({
      presets: [
        presetUno(),
        presetAttributify(),
        presetIcons()
      ],
      theme: {
        colors: {
          primary: '#4299e1',
          secondary: '#718096',
          success: '#48bb78',
          warning: '#ecc94b',
          danger: '#f56565',
        },
        breakpoints: {
          sm: '640px',
          md: '768px',
          lg: '1024px',
          xl: '1280px',
        },
      },
      shortcuts: {
        'btn': 'py-2 px-4 rounded-lg font-medium',
        'btn-primary': 'bg-primary text-white hover:bg-opacity-90',
        'btn-secondary': 'bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-white',
        'card': 'bg-white dark:bg-gray-800 rounded-lg shadow p-4',
      },
      rules: [
        // 自定义规则可以在这里添加
      ],
    }),
    AutoImport({
      resolvers: [VantResolver()],
    }),
    Components({
      resolvers: [VantResolver()],
    }),
  ],
})
